package com.gticket.buyticket.handler;

import com.gticket.buyticket.pojo.Movie;
import com.gticket.buyticket.service.MovieInfoService;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@Data
@RestController
public class MovieInfoHandler {

    @Resource
    private MovieInfoService movieInfoService;

    //遍历所有电影
    @GetMapping("/allMovies")
    public List<Movie> getAllMovies(){
        System.out.println("MovieInfoHandler.getAllMovies+++++++++++++++++"+movieInfoService.getAllMovies());
        return movieInfoService.getAllMovies();
    }

    //电影详情页面
    @GetMapping("/movies")
    public Movie getAllByMovieId(Movie movie){
        return movieInfoService.getAllByMovieId(movie);
    }

    //搜索电影
    @GetMapping("/searchMovie")
    public List<Movie> searchAllMovies(Movie movie_name){
        return movieInfoService.searchAllMovies(movie_name);
    }

    //搜索出电影的数量
    @GetMapping("/searchMovieNumber")
    public int searchMoviesNumber(Movie movie_name){
        return movieInfoService.searchMoviesNumber(movie_name);
    }

}
